package jmine.tec.report.pdf;

import java.io.IOException;
import java.io.OutputStream;

import jmine.tec.report.api.Report;
import jmine.tec.report.export.ReportFileExporter;
import jmine.tec.report.impl.table.pdf.CellRendererPDFRegistry;

/**
 * Implementação de ReportFileExporter que gerar arquivo PDF.
 * 
 * @author lundberg
 */
public class ReportPDFExporter implements ReportFileExporter {

    public static final String RENDERER_TYPE = "pdf";
    
    public static final String PAISAGEM = "PAISAGEM";

    private ReportRendererPDFRegistry reportRendererRegistry;

    private CellRendererPDFRegistry cellRendererRegistry;

	private String logoPath;

    /**
     * {@inheritDoc}
     */
    public void export(OutputStream outputStream, Report report) throws IOException {
        Boolean paisagem = report.getParameters().getBoolean(PAISAGEM, true);
        ReportPDFExporterDelegate delegate = new ReportPDFExporterDelegate(report, this.reportRendererRegistry, this.cellRendererRegistry, paisagem);
        delegate.export(outputStream);
    }

    /**
     * {@inheritDoc}
     */
    public String getLogoPath() {
        return this.logoPath;
    }

    /**
     * @param logoPath the logoPath to set
     */
    public void setLogoPath(String logoPath) {
        this.logoPath = logoPath;
    }

    /**
     * {@inheritDoc}
     */
    public String getRendererType() {
        return RENDERER_TYPE;
    }

    /**
     * @return the reportRendererRegistry
     */
    public ReportRendererPDFRegistry getReportRendererRegistry() {
        return this.reportRendererRegistry;
    }

    /**
     * @return the cellRendererRegistry
     */
    public CellRendererPDFRegistry getCellRendererRegistry() {
        return this.cellRendererRegistry;
    }

    /**
     * @param reportRendererRegistry the reportRendererRegistry to set
     */
    public void setReportRendererRegistry(ReportRendererPDFRegistry reportRendererRegistry) {
        this.reportRendererRegistry = reportRendererRegistry;
    }

    /**
     * @param cellRendererRegistry the cellRendererRegistry to set
     */
    public void setCellRendererRegistry(CellRendererPDFRegistry cellRendererRegistry) {
        this.cellRendererRegistry = cellRendererRegistry;
    }

    /**
     * {@inheritDoc}
     */
    public String getContentType() {
        return "application/pdf";
    }

    /**
     * {@inheritDoc}
     * 
     * @see jmine.tec.report.export.ReportFileExporter#getFileSuffix()
     */
    public String getFileSuffix() {
        return ".pdf";
    }
}
